#-*- coding:utf-8 -*-

#  This is NOT a freeware, use is subject to license terms
#  @author: hzq <151680523@qq.com>

# @version     $Id:filename.php

from pydoc import text
import urllib2
from xml.etree import ElementTree

class readRss:
    def __init__(self, items):
        self.item = items



    def _getString(self, url):
        req = urllib2.Request(url)
        res = urllib2.urlopen(req)
        text = res.read()
        res.close()
        return text
    def xmlParse(self, url):
        """Documentation"""

        root = ElementTree.fromstring(self._getString(url)).getiterator()
        data = []
        
        dic = {}
        begin = False
        tags = False
      
        for node in root:
           
            if begin:
                dic[node.tag] = node.text
               
            if node.tag == self.item:
                
                if begin:
                    data.append(dic)
                begin = True
                dic = {}

              
           
            
        return data


if __name__ == '__main__':
    xml = readRss('item')
    
    # @type xml
    d = xml.xmlParse('http://blog.sina.com.cn/rss/1057579390.xml')
    print d[0]
            
            
            
